<?php

header('Content-Type: text/html; charset=utf-8');

// Valid PHP Version?
$minPHPVersion = '7.2';
if (phpversion() < $minPHPVersion) {
    die("PHP 版本必须 大于 {$minPHPVersion} . 当前版本: " . phpversion());
}

define('WEBPATH', dirname(__FILE__) . '/');
define('WRITEPATH', WEBPATH . 'writable/');

if (!iswrite_path_check(WRITEPATH)) {
    exit('目录（' . $t . '）不可写');
}

header('Location: index.php/install');

// 检查目录权限
function iswrite_path_check($dir)
{
    if (!$dir) {
        return 0;
    } elseif (!is_dir($dir)) {
        return 0;
    }

    $size = @file_put_contents($dir . 'test.html', 'test');
    if ($size === false) {
        return 0;
    } else {
        @unlink($dir . 'test.html');
        return 1;
    }
}
